<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>求职岗位申请</title>
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="../../../plugins/element-ui/index.css">

    <style>
        *{
            margin: 0;
            padding: 0;
        }
    </style>
    <!--    上传图片样式-->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
    </style>

</head>
<body>
<div id="app">


    <!--1.导航栏-->
    <div style="z-index: 999;position:fixed;width: 100%">
        <el-menu
                :default-active="activeIndex2"
                class="el-menu-demo"
                mode="horizontal"
                @select="handleSelect"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b">
            <el-menu-item index="1" @click="url(1)" style="margin-left: 200px">首页</el-menu-item>
            <el-menu-item index="3" @click="url(3)">录用结果</el-menu-item>
            <el-menu-item index="4" @click="url(4)">工资详情|反馈信息</el-menu-item>
            <el-menu-item index="5" @click="url(5)">修改个人信息</el-menu-item>

            <el-submenu index="6"  style="margin-left: 400px">
                <template slot="title"><i class="el-icon-user"></i></template>
                <el-menu-item index="6-2" @click="url(6)">退出登录</el-menu-item>
            </el-submenu>


        </el-menu>
    </div>

    <!--   注： 这个盒子的作用是把轮播图给顶到下面去，避免导航栏position的fixed属性将轮播图给覆盖-->
    <div style="width: 100%;height:58px "></div>

    <!--    标题div-->
    <div style="position:absolute;margin:50px 0 0 70px;  width: 90%;height: 300px;background-color: #f2e2d0">
        <div style="margin:50px 0 0 575px;background-color: black;color:white;width: 200px;height: 45px"><p style="line-height:45px;text-align: center">Welcome</p></div>
        <div style="margin: 0 0 0 350px;"><h1>This is your previous purchase record</h1></div>
        <div @click="toType" style="cursor:pointer;margin:0 0 0 600px;background-color: #24b5e1;color:white;width: 150px;height: 60px"><h2 style="line-height:60px;text-align: center"> TO HOME</h2></div>
    </div>


    <div>

    </div>

</div>




<script src="../../../plugins/vue/vue.js"></script>

<!-- 引入element-ui组件库 -->
<script src="../../../plugins/element-ui/index.js"></script>

<!-- 引入axios -->
<script src="../../../plugins/axios/axios.min.js"></script>

<script>
    new Vue({
        el:'#app',    //element
        data:{

            studentInfo:{}, //当前用户信息

            formData_update:{
                image:''
            },

            options1: [{
                value: '男',
                label: '男'
            },{
                value: '女',
                label: '女'

            },],

            imageUrl1:'',

        },
        created() {
            const studentInfo = window.localStorage.getItem('student')
            console.log("studentInfo1:::"+studentInfo)
            if (studentInfo) {
                this.studentInfo = JSON.parse(studentInfo)
            }
            console.log("studentInfo2:::"+studentInfo)
            if (this.studentInfo==null){
                this.$message.error("您还没登录账号!")
            }
            this.formData_update=this.studentInfo.data
            this.imageUrl = `/files/downloadFile?name=${this.studentInfo.data.image}`



        },
        methods:{
            url(code){
                if (code==1){
                    window.location.href='../index.html';
                }else  if (code==2){
                    window.location.href='teleplay.html';
                }else  if (code==3){
                    window.location.href='applicationResult.html';
                }else  if (code==4){
                    window.location.href='salaryDetails.html';
                }else  if (code==5){
                    window.location.href='updateMyself.html';
                }else  if (code==6){
                    localStorage.setItem('student',null)
                    window.location.href='../../Login/StudentLogin.html';
                }
            },

            //确定修改
            Updatestudent(){
                axios.put("/students/updateStudent",this.formData_update).then((res)=>{
                    if (res.data.code){
                        localStorage.setItem('student',JSON.stringify(res.data))

                        // window.location.href='../student/index.html'

                        this.$message.success("修改个人信息成功")
                    }else{
                        this.$message.error("修改个人信息失败")
                    }
                }).finally(()=>{
                    this.getMyself();
                })
            },

            //4.图片文件上传
            handleAvatarSuccess (response, file, fileList) {
                this.formData_update.image=response.data
                // this.dishAddShow.avatar=<res className="data"></res>;

                this.imageUrl = `/files/downloadFile?name=${response.data}`

                console.log("response:")

                console.log(response)
            },
            beforeUpload (file) {
                if(file){
                    const suffix = file.name.split('.')[1]
                    const size = file.size / 1024 / 1024 < 2
                    if(['png','jpeg','jpg'].indexOf(suffix) < 0){
                        this.$message.error('上传图片只支持 png、jpeg、jpg 格式！')
                        this.$refs.upload.clearFiles()
                        return false
                    }
                    if(!size){
                        this.$message.error('上传文件大小不能超过 2MB!')
                        return false
                    }
                    return file
                }
            },
            getImage (image) {
                this.imageUrl1= `/files/downloadFile?name=${image}`
            },


            toType(){
                window.location.href='../index.html';
            },
        }

    })
</script>

</body>
</html>